{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #A Number After a Double Reversal"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #math"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #数学"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: isSameAfterReversals"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #反转两次的数字"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p><strong>反转</strong> 一个整数意味着倒置它的所有位。</p>\n",
    "\n",
    "<ul>\n",
    "\t<li>例如，反转 <code>2021</code> 得到 <code>1202</code> 。反转 <code>12300</code> 得到 <code>321</code> ，<strong>不保留前导零</strong> 。</li>\n",
    "</ul>\n",
    "\n",
    "<p>给你一个整数 <code>num</code> ，<strong>反转</strong> <code>num</code> 得到 <code>reversed1</code> ，<strong>接着反转</strong> <code>reversed1</code> 得到 <code>reversed2</code> 。如果 <code>reversed2</code> 等于 <code>num</code> ，返回 <code>true</code> ；否则，返回 <code>false</code> 。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>num = 526\n",
    "<strong>输出：</strong>true\n",
    "<strong>解释：</strong>反转 num 得到 625 ，接着反转 625 得到 526 ，等于 num 。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>num = 1800\n",
    "<strong>输出：</strong>false\n",
    "<strong>解释：</strong>反转 num 得到 81 ，接着反转 81 得到 18 ，不等于 num 。 </pre>\n",
    "\n",
    "<p><strong>示例 3：</strong></p>\n",
    "\n",
    "<pre><strong>输入：</strong>num = 0\n",
    "<strong>输出：</strong>true\n",
    "<strong>解释：</strong>反转 num 得到 0 ，接着反转 0 得到 0 ，等于 num 。\n",
    "</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>0 &lt;= num &lt;= 10<sup>6</sup></code></li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [a-number-after-a-double-reversal](https://leetcode.cn/problems/a-number-after-a-double-reversal/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [a-number-after-a-double-reversal](https://leetcode.cn/problems/a-number-after-a-double-reversal/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['526', '1800', '0']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return bool(num % 10) or num == 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        \n",
    "       \n",
    "        a=int(str(num)[::-1])\n",
    "        b=int(str(a)[::-1])\n",
    "        if num==b:\n",
    "            return True\n",
    "        else:\n",
    "            return False    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num==0 or num%10!=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "\n",
    "    def reverse(self, a: int) -> int:\n",
    "        if a < 10:\n",
    "            return a\n",
    "        return int(str(a)[::-1].lstrip('0'))\n",
    "    \n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        a = self.reverse(num)\n",
    "        b = self.reverse(a)\n",
    "        return num == b\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return True if num == 0 else num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:\n",
    "            return True\n",
    "        elif str(num)[-1] == '0':\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num==0:\n",
    "            return True\n",
    "        else:\n",
    "            if num%10==0:\n",
    "                return False\n",
    "            else:\n",
    "                return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if str(num)[-1]==\"0\" and len(str(num))>1:\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num==0:\n",
    "            return True\n",
    "        else:\n",
    "            if num%10==0:\n",
    "                return False\n",
    "            else:\n",
    "                return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num == 0 or num%10 != 0 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num==0 or num%10!=0 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    #---------------------------#\n",
    "    # 反转整数\n",
    "    #---------------------------#\n",
    "    def get(self,num):\n",
    "        x = 0\n",
    "        while num>0:\n",
    "         digital = num % 10\n",
    "         num //=10\n",
    "         x = x*10 + digital\n",
    "        return x\n",
    "\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        #----------------------------#\n",
    "        # 不保留前导零\n",
    "        #----------------------------#\n",
    "        x = self.get(num)\n",
    "        x = int(str(x)[::-1])\n",
    "        #---------直接返回---------#\n",
    "        return x==num\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        s = str(num)\n",
    "        if len(s) == 1:\n",
    "            return True\n",
    "        if s[-1] == '0':\n",
    "            return False\n",
    "        else:\n",
    "            return True "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num == 0 or num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        num = str(num)\n",
    "        if (len(num) > 1 and num[-1] == '0'):\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:\n",
    "            return True\n",
    "        if num%10 == 0:\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    #---------------------------#\n",
    "    # 反转整数\n",
    "    #---------------------------#\n",
    "    def get(self,num):\n",
    "        x = 0\n",
    "        while num>0:\n",
    "         digital = num % 10\n",
    "         num //=10\n",
    "         x = x*10 + digital\n",
    "        return x\n",
    "\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        #----------------------------#\n",
    "        # 不保留前导零\n",
    "        #----------------------------#\n",
    "        x = self.get(num)\n",
    "        x = int(str(x)[::-1])\n",
    "        #---------直接返回---------#\n",
    "        return x==num\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:return True\n",
    "        num = str(num)\n",
    "        r1 = num[::-1]\n",
    "        if len(str(int(r1))) == len(r1):\n",
    "            return True\n",
    "        return False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        '''\n",
    "        string = str(num)\n",
    "        reverse1 = str(int(string[::-1]))\n",
    "        reverse2 = int(reverse1[::-1])\n",
    "        return reverse2 == num\n",
    "        '''\n",
    "\n",
    "        return num == 0 or num % 10 > 0\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num == 0 or num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:\n",
    "            return True\n",
    "        else:\n",
    "            if num % 10 == 0:\n",
    "                return False\n",
    "            else:\n",
    "                return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return True if num == 0 or str(num)[-1] != '0' else False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if(num == 0):\n",
    "            return True\n",
    "        if((num%10)==0):\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return str(num)[-1] != '0' or num == 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:\n",
    "            return True\n",
    "        return False if str(num)[-1] == \"0\" else True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        string = str(num)\n",
    "        reverse1 = str(int(string[::-1]))\n",
    "        reverse2 = int(reverse1[::-1])\n",
    "        return reverse2 == num\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num==0 or num%10!=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num == 0 or num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:\n",
    "            return True\n",
    "        if num % 10 == 0:\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0 :\n",
    "            return True\n",
    "        return num%10!=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        list1 = [i for i in str(num)]\n",
    "        first_list = list1[::-1]\n",
    "        first_num = int(\"\".join(i for i in first_list))\n",
    "        second_list = [i for i in str(first_num)[::-1]]\n",
    "        return num == int(\"\".join(i for i in second_list))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num == 0 or num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "         reversed1=str(num)[::-1]\n",
    "         for i in range(len(reversed1)):\n",
    "             if reversed1[i]!='0':\n",
    "                 break\n",
    "         if i==0:\n",
    "             return True\n",
    "         else:\n",
    "             return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return  num % 10 > 0 or num == 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        num1=str(num)[::-1]\n",
    "        for i in range(len(num1)):\n",
    "            if num1[i]!='0':\n",
    "                num1=num1[i:]\n",
    "                break\n",
    "        num2=num1[::-1]\n",
    "\n",
    "\n",
    "\n",
    "        if num2==str(num):\n",
    "            return True\n",
    "        else:\n",
    "            return False\n",
    "print(Solution().isSameAfterReversals(526))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        s = str(num)\n",
    "        if s == '0':\n",
    "            return True\n",
    "        if s.endswith('0'):\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:\n",
    "            return True\n",
    "        if num % 10 == 0:\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num==0:\n",
    "            return True\n",
    "        if num<0 or num%10==0:\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num % 10 != 0 if num != 0 else True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return True if not num or int(str(num)[-1]) else False"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num==0:\n",
    "            return True\n",
    "        if num%10==0:\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if set(str(num)) == set(\"0\"):\n",
    "            return True\n",
    "        else:\n",
    "            return (re.sub(r\"^0+\", \"\", str(num)[::-1]))[::-1] == str(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return False if num % 10 == 0 and num != 0 else True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        a = str(num)\n",
    "        b = a[::-1]\n",
    "        c = int(b)\n",
    "        d = str(c)\n",
    "        e = d[::-1]\n",
    "        f = int(e)\n",
    "        return f==num"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return True if num == 0 else num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num % 10 == 0 and num != 0:\n",
    "            return False\n",
    "        else:\n",
    "            return True\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num==0:\n",
    "            return True\n",
    "        return num%10!=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "      return num == 0 or num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num % 10 == 0 and num != 0:\n",
    "            return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        ts=int(str(num)[::-1])\n",
    "        if int(str(ts)[::-1])==num:\n",
    "            return True\n",
    "        else:\n",
    "            return False\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return 0 == num or num %10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num == 0 or num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num==0:\n",
    "            return True\n",
    "        else:\n",
    "            if str(num)[-1]=='0':\n",
    "                return False\n",
    "            else:\n",
    "                return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        num=str(num)\n",
    "        left,right=0,len(num)-1\n",
    "        while left<right:\n",
    "            if num[left]==\"0\" and num[right]==\"0\":\n",
    "                left+=1\n",
    "                right-=1\n",
    "            elif num[left]!=\"0\" and num[right]!=\"0\":\n",
    "                return True\n",
    "            else:\n",
    "                return False\n",
    "        return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        return num==0 or num%10!=0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num < 0: return False\n",
    "        #print(int(str(num)[::-1]))\n",
    "        return num == 0 or num % 10 != 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "         if num==0:\n",
    "            return True\n",
    "         \n",
    "         if num%10!=0:\n",
    "             return True\n",
    "         else:\n",
    "             return False\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num == 0:\n",
    "            return True\n",
    "        if num % 10 == 0:\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def isSameAfterReversals(self, num: int) -> bool:\n",
    "        if num==0:\n",
    "           return True\n",
    "        x=list(str(num))\n",
    "        if x[0]=='0' or x[-1] == '0':\n",
    "            return False\n",
    "        else:\n",
    "            return True"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
